package com.shunbo.convenient.controller;

import com.shunbo.convenient.service.NavService;
import com.shunbo.convenient.utils.ConvenientResult;
import com.shunbo.convenient.vo.Coupon;
import com.shunbo.convenient.vo.CouponOrder;
import com.shunbo.convenient.vo.Nav;
import com.shunbo.convenient.vo.Opinion;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author weizhuang
 * 导航
 */
@RestController
@RequestMapping("/nav")
public class NavController {


    @Resource
    private NavService navService;


    /**
     * 导航列表
     *
     * @return Result结果集
     */
    @RequestMapping("/list")
    public ConvenientResult getNavList(@RequestBody Nav nav) {
        try {
            List<Nav> all = navService.findAll(nav);
            return ConvenientResult.build(200, "成功", all);
        } catch (Exception e) {
            e.printStackTrace();
            return ConvenientResult.build(500, "系统错误", e.getStackTrace());
        }
    }

    /**
     * 更新导航
     * @param nav 导航信息
     * @return Result结果集
     */
    @RequestMapping("/update")
    public ConvenientResult updateOpinion(@RequestBody Nav nav){
        try {
            Integer save = navService.update(nav);
            return ConvenientResult.build(200,"成功",save);
        }catch (Exception e){
            e.printStackTrace();
            return ConvenientResult.build(500,"系统错误",e.getStackTrace());
        }
    }

}
